﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace CardPlay.Model.CardModel
{
    public static class DeckFactory
    {
        public static IEnumerable<Card> CreateStandardDeck(int backDesign = 0)
        {
            return CardFace.StandardSet.Select(face => new Card(face, backDesign));
        }

        public static IEnumerable<Card> CreateStrippedDeck(Predicate<CardFace> filter, int standardSets = 1)
        {
            return CombineCards(standardSets, design => CreateStandardDeck(design).Where(card => filter(card)));
        }

        public static IEnumerable<Card> CombineIdenticalDecks(int standardSets, int backDesign = 0)
        {
            return CombineCards(standardSets, design => CreateStandardDeck(backDesign));
        }

        public static IEnumerable<Card> CombineCards(int setCount, Func<int, IEnumerable<Card>> setBuilder)
        {
            return Enumerable.Range(0, setCount).SelectMany(setBuilder);
        }
    }
}
